網際內容管理系統在精密機械教學與研究上的應用

  • Home
    • Site Map
    • reveal
    • blog
  • About
  • 主機設定
    • Windows 10
      • Win 網站簽章
      • Win Oauth2
      • Oauth2 原理
      • Nginx
    • Ubuntu設定
      • Ubuntu 簽章
      • 配置 uwsgi
      • xrdp
  • fossiloauth
    • foauth_config
  • fossilapp
  • Fossil
  • 專題報告
  • Reference
    • Flutter
      • Flutter ref
    • discourse
      • 操作管理
    • cd2020pj1
      • Oauth2
    • Network
    • Ref
      • LaTeX
      • Automatic Control
      • 參考步驟
      • ebook1
      • Project
      • Ref2
      • Bond Graphs
      • KMOLBrowser
      • Glowscript
      • Rapydscript
      • Atoms
      • Samples
      • RLearning
      • Ebooks
      • Feedback
      • CMSiMDE
      • Git
      • Windows
      • Ubuntu
      • Heorku
      • Certbot
Ubuntu設定 << Previous Next >> 配置 uwsgi

Ubuntu 簽章

連線至 https://certbot.eff.org/lets-encrypt/ubuntufocal-nginx

snap 上網之前, 必須檢查 /etc/environment 中的代理主機設定.

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
HTTPS=on
http_proxy=http://[2001:288:6004:17::Proxy_ip]:3128
https_proxy=http://[2001:288:6004:17::Proxy_ip]:3128

其中的 HTTPS=on 是針對 Stunnel, 而 http_proxy 與 https_proxy 則可為 snap 安裝套件時採用.

首先確定 snapd 使用最新版本:

sudo snap install core; sudo snap refresh core

接著安裝 certbot:

sudo snap install --classic certbot

sudo ln -s /snap/bin/certbot /usr/bin/certbot

只取 certificate:

sudo certbot certonly --nginx

一旦執行完成, 即可取得與 domain name 對應的 certificates:

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/domain_name/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/domain_name/privkey.pem

之後利用 sudo cp -r /etc/letsencrypt/archive /home/wcm2021/, 然後利用 sudo chown -R wcm2021:wcm2021 /home/wcm2021/archive, 接著將 archive 目錄中的 fullchain.pem 與 privkey.pem 複製至 /etc/stunnel/, 然後編輯 stunnel.conf, 利用 fullchain.pem 取代 localhost.crt, 利用 privkey.pem 取代 localhost.key, 重新啟動 stunnel:

sudo /etc/init.d/stunnel4 restart

之後 Stunnel (也就是 Fossil SCM server) 應該就可以正確使用 https 協定.

接著編輯 /etc/nginx/sites-available/default, 將 localhost.crt 換為 fullchain.pem, localhost.key 換為 privkey.pem, 然後以 /etc/init.d/nginx restart 重新啟動 nginx, 之後的 Flask 網際程式應該就能以正式的 https 連線.

測試自動 renew certificate:

sudo certbot renew --dry-run


Ubuntu設定 << Previous Next >> 配置 uwsgi

Copyright © All rights reserved | This template is made with by Colorlib